https://encrypted-tbn0.gstatic.com/shopping?q=tbn:ANd9GcTdsig5Pff0SRN-6gzZ8MY3Va6_-G2AEzd4rBeoOaZHnYdWXd56WE2qFSIdvPss72E2B4U8KsXOcpOQUl7jxD3uVSKX28bk6CSsRHf1M7Ga&usqp=CAE

<template>

  <el-card style="width: 500px; padding: 20px;border: 1px solid #cccccc" >

    <el-form label-width="80px" size="small">
      <el-form-item label="用户名" >
        <el-input v-model="form.username" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="昵称" >
        <el-input v-model="form.nickname" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="邮箱" >
        <el-input v-model="form.email" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="电话" >
        <el-input v-model="form.phone" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="地址" >
        <el-input v-model="form.address" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="save">确 定</el-button>
      </el-form-item>

    </el-form>

  </el-card>


</template>


<script>
import request from "@/utils/request";

export default {
  name: "PersonalMsg",
  data(){
    return {
      form: {},
      user: localStorage.getItem("user") ? JSON.parse(localStorage.getItem("user")) : {},

    }
  },
  created() {

    let userName = this.user.username;
    console.log(userName);


    this.request.get("/user/username/" + this.user.id).then((res) => {

      if (res !== null){
         this.form = res

      }
    })

  },
  methods:{
    save(){
      request.post("/user/person",this.form).then((res)=>{
        if (res){
          this.$message.success("插入成功")
          this.dialogFormVisible = false;
          this.load();
        }else {
          this.$message.error("插入失败")
        }
      })
    },
  }
}
</script>

<style scoped>

</style>
